/*
 * MTZenCoding.js
 *
 * Since:     2010-02-22
 * Modified:  2010-02-22
 *
 * jQuery 1.3.x
 *
 */

// テキストエリアの現在のカーソル(キャレット)位置に文字を挿入するには - エンジニアきまぐれTips [start]
$.fn.extend({
    insertAtCaret: function(v) {
      var o = this.get(0);
      o.focus();
      if (jQuery.browser.msie) {
        var r = document.selection.createRange();
        r.text = v;
        r.select();
      } else {
        var s = o.value;
        var p = o.selectionStart;
        var np = p + v.length;
        o.value = s.substr(0, p) + v + s.substr(p);
        o.setSelectionRange(np, np);
      }
    }
});
// http://d.hatena.ne.jp/okinaka/20090727/1248671860 [ end ]

jQuery(function($){
    // getPageScroll() by quirksmode.com [start]
    function getPageScroll() {
      var xScroll, yScroll;
      if (self.pageYOffset) {
        yScroll = self.pageYOffset;
        xScroll = self.pageXOffset;
      } else if (document.documentElement && document.documentElement.scrollTop) {   // Explorer 6 Strict
        yScroll = document.documentElement.scrollTop;
        xScroll = document.documentElement.scrollLeft;
      } else if (document.body) {// all other Explorers
        yScroll = document.body.scrollTop;
        xScroll = document.body.scrollLeft; 
      }
      return new Array(xScroll,yScroll);
    }
    // getPageScroll() by quirksmode.com [ end ]
    
    // Adapted from getPageSize() by quirksmode.com [start]
    function getPageHeight() {
      var windowHeight
      if (self.innerHeight) {   // all except Explorer
        windowHeight = self.innerHeight;
      } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowHeight = document.documentElement.clientHeight;
      } else if (document.body) { // other Explorers
        windowHeight = document.body.clientHeight;
      } 
      return windowHeight;
    }
    // Adapted from getPageSize() by quirksmode.com [start]

    // Get elements
    var body = $('body');
    var container = $('#container');
    var tmpl_body = $('#template-body-field');
    var textarea = $('#text');
    
    // Setting style
    textarea.css({
        'height':'500px'
    });
    
    // MTTags
    var mttags = [
        '<option title="mtactstr">ActionStreams</option>',
        '<option title="mtacts">Actions</option>',
        '<option title="mtactscom">ActionsComment</option>',
        '<option title="mtactsent">ActionsEntry</option>',
        '<option title="mtactsfav">ActionsFavorite</option>',
        '<option title="mtactsfoo">ActionsFooter</option>',
        '<option title="mtactshea">ActionsHeader</option>',
        '<option title="mtadmcgipat">AdminCGIPath</option>',
        '<option title="mtadmscr">AdminScript</option>',
        '<option title="mtappactbar">App:ActionBar</option>',
        '<option title="mtappfor">App:Form</option>',
        '<option title="mtapplin">App:Link</option>',
        '<option title="mtapplisfil">App:ListFilters</option>',
        '<option title="mtapplising">App:Listing</option>',
        '<option title="mtapppagacts">App:PageActions</option>',
        '<option title="mtappset">App:Setting</option>',
        '<option title="mtappsetgro">App:SettingGroup</option>',
        '<option title="mtappstamsg">App:StatusMsg</option>',
        '<option title="mtappwid">App:Widget</option>',
        '<option title="mtarccat">ArchiveCategory</option>',
        '<option title="mtarccou">ArchiveCount</option>',
        '<option title="mtarcdat">ArchiveDate</option>',
        '<option title="mtarcdatend">ArchiveDateEnd</option>',
        '<option title="mtarcfil">ArchiveFile</option>',
        '<option title="mtarclab">ArchiveLabel</option>',
        '<option title="mtarclin">ArchiveLink</option>',
        '<option title="mtarclis">ArchiveList</option>',
        '<option title="mtarclisfoo">ArchiveListFooter</option>',
        '<option title="mtarclishea">ArchiveListHeader</option>',
        '<option title="mtarcnex">ArchiveNext</option>',
        '<option title="mtarcpre">ArchivePrevious</option>',
        '<option title="mtarctit">ArchiveTitle</option>',
        '<option title="mtarctyp">ArchiveType</option>',
        '<option title="mtarctyplab">ArchiveTypeLabel</option>',
        '<option title="mtarcs">Archives</option>',
        '<option title="mtass">Asset</option>',
        '<option title="mtassaddby">AssetAddedBy</option>',
        '<option title="mtasscou">AssetCount</option>',
        '<option title="mtassdatadd">AssetDateAdded</option>',
        '<option title="mtassdes">AssetDescription</option>',
        '<option title="mtassfilext">AssetFileExt</option>',
        '<option title="mtassfilnam">AssetFileName</option>',
        '<option title="mtassfilpat">AssetFilePath</option>',
        '<option title="mtassid">AssetID</option>',
        '<option title="mtassiftagged">AssetIfTagged</option>',
        '<option title="mtassisfirinrow">AssetIsFirstInRow</option>',
        '<option title="mtassislasinrow">AssetIsLastInRow</option>',
        '<option title="mtasslab">AssetLabel</option>',
        '<option title="mtasslin">AssetLink</option>',
        '<option title="mtassmintyp">AssetMimeType</option>',
        '<option title="mtasspro">AssetProperty</option>',
        '<option title="mtassran">AssetRank</option>',
        '<option title="mtasssco">AssetScore</option>',
        '<option title="mtassscoavg">AssetScoreAvg</option>',
        '<option title="mtassscocou">AssetScoreCount</option>',
        '<option title="mtassscohig">AssetScoreHigh</option>',
        '<option title="mtassscolow">AssetScoreLow</option>',
        '<option title="mtasstags">AssetTags</option>',
        '<option title="mtassthulin">AssetThumbnailLink</option>',
        '<option title="mtassthuurl">AssetThumbnailURL</option>',
        '<option title="mtasstyp">AssetType</option>',
        '<option title="mtassurl">AssetURL</option>',
        '<option title="mtasss">Assets</option>',
        '<option title="mtasssfoo">AssetsFooter</option>',
        '<option title="mtassshea">AssetsHeader</option>',
        '<option title="mtatoscr">AtomScript</option>',
        '<option title="mtaudcusdes">AudioCustomFieldDescription</option>',
        '<option title="mtaudcusnam">AudioCustomFieldName</option>',
        '<option title="mtaudcusval">AudioCustomFieldValue</option>',
        '<option title="mtaudcuss">AudioCustomFields</option>',
        '<option title="mtautauticourl">AuthorAuthIconURL</option>',
        '<option title="mtautauttyp">AuthorAuthType</option>',
        '<option title="mtautbas">AuthorBasename</option>',
        '<option title="mtautcomcou">AuthorCommentCount</option>',
        '<option title="mtautcomres">AuthorCommentResponses</option>',
        '<option title="mtautcoms">AuthorComments</option>',
        '<option title="mtautcusdes">AuthorCustomFieldDescription</option>',
        '<option title="mtautcusnam">AuthorCustomFieldName</option>',
        '<option title="mtautcusval">AuthorCustomFieldValue</option>',
        '<option title="mtautcuss">AuthorCustomFields</option>',
        '<option title="mtautdisnam">AuthorDisplayName</option>',
        '<option title="mtautema">AuthorEmail</option>',
        '<option title="mtautentscou">AuthorEntriesCount</option>',
        '<option title="mtautentcou">AuthorEntryCount</option>',
        '<option title="mtautfollin">AuthorFollowLink</option>',
        '<option title="mtautfolers">AuthorFollowers</option>',
        '<option title="mtautfolerscou">AuthorFollowersCount</option>',
        '<option title="mtautfol">AuthorFollowing</option>',
        '<option title="mtautfolcoms">AuthorFollowingComments</option>',
        '<option title="mtautfolcou">AuthorFollowingCount</option>',
        '<option title="mtautfolents">AuthorFollowingEntries</option>',
        '<option title="mtautfolfav">AuthorFollowingFavorites</option>',
        '<option title="mtauthasent">AuthorHasEntry</option>',
        '<option title="mtauthaspag">AuthorHasPage</option>',
        '<option title="mtautid">AuthorID</option>',
        '<option title="mtautiffoled">AuthorIfFollowed</option>',
        '<option title="mtautiffol">AuthorIfFollowing</option>',
        '<option title="mtautnam">AuthorName</option>',
        '<option title="mtautnex">AuthorNext</option>',
        '<option title="mtautpre">AuthorPrevious</option>',
        '<option title="mtautran">AuthorRank</option>',
        '<option title="mtautsco">AuthorScore</option>',
        '<option title="mtautscoavg">AuthorScoreAvg</option>',
        '<option title="mtautscocou">AuthorScoreCount</option>',
        '<option title="mtautscohig">AuthorScoreHigh</option>',
        '<option title="mtautscolow">AuthorScoreLow</option>',
        '<option title="mtauturl">AuthorURL</option>',
        '<option title="mtautunfollin">AuthorUnFollowLink</option>',
        '<option title="mtautusepic">AuthorUserpic</option>',
        '<option title="mtautusepicass">AuthorUserpicAsset</option>',
        '<option title="mtautusepicurl">AuthorUserpicURL</option>',
        '<option title="mtauts">Authors</option>',
        '<option title="mtbloarcurl">BlogArchiveURL</option>',
        '<option title="mtblocclima">BlogCCLicenseImage</option>',
        '<option title="mtblocclurl">BlogCCLicenseURL</option>',
        '<option title="mtblocatcou">BlogCategoryCount</option>',
        '<option title="mtblocomcou">BlogCommentCount</option>',
        '<option title="mtblocusdes">BlogCustomFieldDescription</option>',
        '<option title="mtblocusnam">BlogCustomFieldName</option>',
        '<option title="mtblocusval">BlogCustomFieldValue</option>',
        '<option title="mtblocuss">BlogCustomFields</option>',
        '<option title="mtblodes">BlogDescription</option>',
        '<option title="mtbloentcou">BlogEntryCount</option>',
        '<option title="mtblofilext">BlogFileExtension</option>',
        '<option title="mtblohos">BlogHost</option>',
        '<option title="mtbloid">BlogID</option>',
        '<option title="mtbloifccl">BlogIfCCLicense</option>',
        '<option title="mtbloifcomsope">BlogIfCommentsOpen</option>',
        '<option title="mtblolan">BlogLanguage</option>',
        '<option title="mtblonam">BlogName</option>',
        '<option title="mtblopagcou">BlogPageCount</option>',
        '<option title="mtbloparweb">BlogParentWebsite</option>',
        '<option title="mtblopincou">BlogPingCount</option>',
        '<option title="mtblorelurl">BlogRelativeURL</option>',
        '<option title="mtbloresfoo">BlogResultFooter</option>',
        '<option title="mtbloreshea">BlogResultHeader</option>',
        '<option title="mtblositpat">BlogSitePath</option>',
        '<option title="mtblotemsetid">BlogTemplateSetID</option>',
        '<option title="mtblotheid">BlogThemeID</option>',
        '<option title="mtblotim">BlogTimezone</option>',
        '<option title="mtblourl">BlogURL</option>',
        '<option title="mtblos">Blogs</option>',
        '<option title="mtbuitemid">BuildTemplateID</option>',
        '<option title="mtcclrdf">CCLicenseRDF</option>',
        '<option title="mtcgihos">CGIHost</option>',
        '<option title="mtcgipat">CGIPath</option>',
        '<option title="mtcgirelurl">CGIRelativeURL</option>',
        '<option title="mtcgiserpat">CGIServerPath</option>',
        '<option title="mtcal">Calendar</option>',
        '<option title="mtcalcelnum">CalendarCellNumber</option>',
        '<option title="mtcaldat">CalendarDate</option>',
        '<option title="mtcalday">CalendarDay</option>',
        '<option title="mtcalifbla">CalendarIfBlank</option>',
        '<option title="mtcalifents">CalendarIfEntries</option>',
        '<option title="mtcalifnoents">CalendarIfNoEntries</option>',
        '<option title="mtcaliftod">CalendarIfToday</option>',
        '<option title="mtcalweefoo">CalendarWeekFooter</option>',
        '<option title="mtcalweehea">CalendarWeekHeader</option>',
        '<option title="mtcapfie">CaptchaFields</option>',
        '<option title="mtcats">Categories</option>',
        '<option title="mtcatarclin">CategoryArchiveLink</option>',
        '<option title="mtcatbas">CategoryBasename</option>',
        '<option title="mtcatcomcou">CategoryCommentCount</option>',
        '<option title="mtcatcou">CategoryCount</option>',
        '<option title="mtcatcusdes">CategoryCustomFieldDescription</option>',
        '<option title="mtcatcusnam">CategoryCustomFieldName</option>',
        '<option title="mtcatcusval">CategoryCustomFieldValue</option>',
        '<option title="mtcatcuss">CategoryCustomFields</option>',
        '<option title="mtcatdes">CategoryDescription</option>',
        '<option title="mtcatid">CategoryID</option>',
        '<option title="mtcatifallpins">CategoryIfAllowPings</option>',
        '<option title="mtcatlab">CategoryLabel</option>',
        '<option title="mtcatnex">CategoryNext</option>',
        '<option title="mtcatpre">CategoryPrevious</option>',
        '<option title="mtcattracou">CategoryTrackbackCount</option>',
        '<option title="mtcattralin">CategoryTrackbackLink</option>',
        '<option title="mtcomaut">CommentAuthor</option>',
        '<option title="mtcomautide">CommentAuthorIdentity</option>',
        '<option title="mtcomautlin">CommentAuthorLink</option>',
        '<option title="mtcombloid">CommentBlogID</option>',
        '<option title="mtcombod">CommentBody</option>',
        '<option title="mtcomcusdes">CommentCustomFieldDescription</option>',
        '<option title="mtcomcusnam">CommentCustomFieldName</option>',
        '<option title="mtcomcusval">CommentCustomFieldValue</option>',
        '<option title="mtcomcuss">CommentCustomFields</option>',
        '<option title="mtcomdat">CommentDate</option>',
        '<option title="mtcomema">CommentEmail</option>',
        '<option title="mtcoment">CommentEntry</option>',
        '<option title="mtcomentid">CommentEntryID</option>',
        '<option title="mtcomid">CommentID</option>',
        '<option title="mtcomip">CommentIP</option>',
        '<option title="mtcomifmod">CommentIfModerated</option>',
        '<option title="mtcomlin">CommentLink</option>',
        '<option title="mtcomnam">CommentName</option>',
        '<option title="mtcomordnum">CommentOrderNumber</option>',
        '<option title="mtcompar">CommentParent</option>',
        '<option title="mtcomparid">CommentParentID</option>',
        '<option title="mtcompreaut">CommentPreviewAuthor</option>',
        '<option title="mtcompreautlin">CommentPreviewAuthorLink</option>',
        '<option title="mtcomprebod">CommentPreviewBody</option>',
        '<option title="mtcompredat">CommentPreviewDate</option>',
        '<option title="mtcompreema">CommentPreviewEmail</option>',
        '<option title="mtcompreip">CommentPreviewIP</option>',
        '<option title="mtcompreissta">CommentPreviewIsStatic</option>',
        '<option title="mtcompreurl">CommentPreviewURL</option>',
        '<option title="mtcomran">CommentRank</option>',
        '<option title="mtcomrep">CommentReplies</option>',
        '<option title="mtcomreprec">CommentRepliesRecurse</option>',
        '<option title="mtcomsco">CommentScore</option>',
        '<option title="mtcomscoavg">CommentScoreAvg</option>',
        '<option title="mtcomscocou">CommentScoreCount</option>',
        '<option title="mtcomscohig">CommentScoreHigh</option>',
        '<option title="mtcomscolow">CommentScoreLow</option>',
        '<option title="mtcomscr">CommentScript</option>',
        '<option title="mtcomurl">CommentURL</option>',
        '<option title="mtcomerauticourl">CommenterAuthIconURL</option>',
        '<option title="mtcomerauttyp">CommenterAuthType</option>',
        '<option title="mtcomerema">CommenterEmail</option>',
        '<option title="mtcomerid">CommenterID</option>',
        '<option title="mtcomeriftru">CommenterIfTrusted</option>',
        '<option title="mtcomernam">CommenterName</option>',
        '<option title="mtcomernamthu">CommenterNameThunk</option>',
        '<option title="mtcomerurl">CommenterURL</option>',
        '<option title="mtcomerusename">CommenterUsername</option>',
        '<option title="mtcomerusepic">CommenterUserpic</option>',
        '<option title="mtcomerusepicass">CommenterUserpicAsset</option>',
        '<option title="mtcomerusepicurl">CommenterUserpicURL</option>',
        '<option title="mtcoms">Comments</option>',
        '<option title="mtcomsfoo">CommentsFooter</option>',
        '<option title="mtcomshea">CommentsHeader</option>',
        '<option title="mtcommscr">CommunityScript</option>',
        '<option title="mtconfil">ConfigFile</option>',
        '<option title="mtcurpag">CurrentPage</option>',
        '<option title="mtcusbas">CustomFieldBasename</option>',
        '<option title="mtcusdes">CustomFieldDescription</option>',
        '<option title="mtcusthm">CustomFieldHTML</option>',
        '<option title="mtcusisreq">CustomFieldIsRequired</option>',
        '<option title="mtcusnam">CustomFieldName</option>',
        '<option title="mtcusval">CustomFieldValue</option>',
        '<option title="mtdate">Date</option>',
        '<option title="mtdatefoo">DateFooter</option>',
        '<option title="mtdatehea">DateHeader</option>',
        '<option title="mtdeflan">DefaultLanguage</option>',
        '<option title="mtels">Else</option>',
        '<option title="mtelsif">ElseIf</option>',
        '<option title="mtents">Entries</option>',
        '<option title="mtentscou">EntriesCount</option>',
        '<option title="mtentsfoo">EntriesFooter</option>',
        '<option title="mtentshea">EntriesHeader</option>',
        '<option title="mtentswitsubcats">EntriesWithSubCategories</option>',
        '<option title="mtentaddcats">EntryAdditionalCategories</option>',
        '<option title="mtentasss">EntryAssets</option>',
        '<option title="mtentatoid">EntryAtomID</option>',
        '<option title="mtentaud">EntryAudio</option>',
        '<option title="mtentaut">EntryAuthor</option>',
        '<option title="mtentautdisnam">EntryAuthorDisplayName</option>',
        '<option title="mtentautema">EntryAuthorEmail</option>',
        '<option title="mtentautid">EntryAuthorID</option>',
        '<option title="mtentautlin">EntryAuthorLink</option>',
        '<option title="mtentautnic">EntryAuthorNickname</option>',
        '<option title="mtentauturl">EntryAuthorURL</option>',
        '<option title="mtentautusename">EntryAuthorUsername</option>',
        '<option title="mtentautusepic">EntryAuthorUserpic</option>',
        '<option title="mtentautusepicass">EntryAuthorUserpicAsset</option>',
        '<option title="mtentautusepicurl">EntryAuthorUserpicURL</option>',
        '<option title="mtentbas">EntryBasename</option>',
        '<option title="mtentblodes">EntryBlogDescription</option>',
        '<option title="mtentbloid">EntryBlogID</option>',
        '<option title="mtentblonam">EntryBlogName</option>',
        '<option title="mtentblourl">EntryBlogURL</option>',
        '<option title="mtentbod">EntryBody</option>',
        '<option title="mtentcats">EntryCategories</option>',
        '<option title="mtentcat">EntryCategory</option>',
        '<option title="mtentcla">EntryClass</option>',
        '<option title="mtentclalab">EntryClassLabel</option>',
        '<option title="mtentcomcou">EntryCommentCount</option>',
        '<option title="mtentcreddat">EntryCreatedDate</option>',
        '<option title="mtentcusdes">EntryCustomFieldDescription</option>',
        '<option title="mtentcusnam">EntryCustomFieldName</option>',
        '<option title="mtentcusval">EntryCustomFieldValue</option>',
        '<option title="mtentcuss">EntryCustomFields</option>',
        '<option title="mtentdat">EntryDate</option>',
        '<option title="mtentedilin">EntryEditLink</option>',
        '<option title="mtentembcod">EntryEmbedCode</option>',
        '<option title="mtentexc">EntryExcerpt</option>',
        '<option title="mtentfla">EntryFlag</option>',
        '<option title="mtentid">EntryID</option>',
        '<option title="mtentifallcoms">EntryIfAllowComments</option>',
        '<option title="mtentifallpins">EntryIfAllowPings</option>',
        '<option title="mtentifcat">EntryIfCategory</option>',
        '<option title="mtentifcomsope">EntryIfCommentsOpen</option>',
        '<option title="mtentifext">EntryIfExtended</option>',
        '<option title="mtentiftagged">EntryIfTagged</option>',
        '<option title="mtentkey">EntryKeywords</option>',
        '<option title="mtentlin">EntryLink</option>',
        '<option title="mtentlinurl">EntryLinkURL</option>',
        '<option title="mtentmoddat">EntryModifiedDate</option>',
        '<option title="mtentmor">EntryMore</option>',
        '<option title="mtentnex">EntryNext</option>',
        '<option title="mtentper">EntryPermalink</option>',
        '<option title="mtentpho">EntryPhoto</option>',
        '<option title="mtentpostyp">EntryPostType</option>',
        '<option title="mtentpre">EntryPrevious</option>',
        '<option title="mtentran">EntryRank</option>',
        '<option title="mtentrawpostyp">EntryRawPostType</option>',
        '<option title="mtentrecvotlin">EntryRecommendVoteLink</option>',
        '<option title="mtentrectot">EntryRecommendedTotal</option>',
        '<option title="mtentsco">EntryScore</option>',
        '<option title="mtentscoavg">EntryScoreAvg</option>',
        '<option title="mtentscocou">EntryScoreCount</option>',
        '<option title="mtentscohig">EntryScoreHigh</option>',
        '<option title="mtentscolow">EntryScoreLow</option>',
        '<option title="mtentsta">EntryStatus</option>',
        '<option title="mtenttags">EntryTags</option>',
        '<option title="mtenttit">EntryTitle</option>',
        '<option title="mtenttracou">EntryTrackbackCount</option>',
        '<option title="mtenttradat">EntryTrackbackData</option>',
        '<option title="mtenttraid">EntryTrackbackID</option>',
        '<option title="mtenttralin">EntryTrackbackLink</option>',
        '<option title="mterrmes">ErrorMessage</option>',
        '<option title="mtfee">Feed</option>',
        '<option title="mtfeeents">FeedEntries</option>',
        '<option title="mtfeeentlin">FeedEntryLink</option>',
        '<option title="mtfeeenttit">FeedEntryTitle</option>',
        '<option title="mtfeeinc">FeedInclude</option>',
        '<option title="mtfeelin">FeedLink</option>',
        '<option title="mtfeetit">FeedTitle</option>',
        '<option title="mtfeebacksco">FeedbackScore</option>',
        '<option title="mtfilcusdes">FileCustomFieldDescription</option>',
        '<option title="mtfilcusnam">FileCustomFieldName</option>',
        '<option title="mtfilcusval">FileCustomFieldValue</option>',
        '<option title="mtfilcuss">FileCustomFields</option>',
        '<option title="mtfiltem">FileTemplate</option>',
        '<option title="mtfolbas">FolderBasename</option>',
        '<option title="mtfolcou">FolderCount</option>',
        '<option title="mtfolcusdes">FolderCustomFieldDescription</option>',
        '<option title="mtfolcusnam">FolderCustomFieldName</option>',
        '<option title="mtfolcusval">FolderCustomFieldValue</option>',
        '<option title="mtfolcuss">FolderCustomFields</option>',
        '<option title="mtfoldes">FolderDescription</option>',
        '<option title="mtfolfoo">FolderFooter</option>',
        '<option title="mtfolhea">FolderHeader</option>',
        '<option title="mtfolid">FolderID</option>',
        '<option title="mtfollab">FolderLabel</option>',
        '<option title="mtfolnex">FolderNext</option>',
        '<option title="mtfolpat">FolderPath</option>',
        '<option title="mtfolpre">FolderPrevious</option>',
        '<option title="mtfols">Folders</option>',
        '<option title="mtfor">For</option>',
        '<option title="mtget">GetVar</option>',
        '<option title="mthtttyp">HTTPContentType</option>',
        '<option title="mthasnoparcat">HasNoParentCategory</option>',
        '<option title="mthasnosubcats">HasNoSubCategories</option>',
        '<option title="mthasparcat">HasParentCategory</option>',
        '<option title="mthasparfol">HasParentFolder</option>',
        '<option title="mthassubcats">HasSubCategories</option>',
        '<option title="mthassubfols">HasSubFolders</option>',
        '<option title="mtif">If</option>',
        '<option title="mtifallcomhtm">IfAllowCommentHTML</option>',
        '<option title="mtifanorecall">IfAnonymousRecommendAllowed</option>',
        '<option title="mtifarctyp">IfArchiveType</option>',
        '<option title="mtifarctypena">IfArchiveTypeEnabled</option>',
        '<option title="mtifblo">IfBlog</option>',
        '<option title="mtifcat">IfCategory</option>',
        '<option title="mtifcompar">IfCommentParent</option>',
        '<option title="mtifcomrep">IfCommentReplies</option>',
        '<option title="mtifcomerisaut">IfCommenterIsAuthor</option>',
        '<option title="mtifcomerisentaut">IfCommenterIsEntryAuthor</option>',
        '<option title="mtifcomertru">IfCommenterTrusted</option>',
        '<option title="mtifcomsacc">IfCommentsAccepted</option>',
        '<option title="mtifcomsact">IfCommentsActive</option>',
        '<option title="mtifcomsalled">IfCommentsAllowed</option>',
        '<option title="mtifcomsmod">IfCommentsModerated</option>',
        '<option title="mtifcurpag">IfCurrentPage</option>',
        '<option title="mtifdyn">IfDynamic</option>',
        '<option title="mtifentrec">IfEntryRecommended</option>',
        '<option title="mtiffol">IfFolder</option>',
        '<option title="mtifimasup">IfImageSupport</option>',
        '<option title="mtifisanc">IfIsAncestor</option>',
        '<option title="mtifisdes">IfIsDescendant</option>',
        '<option title="mtiflogin">IfLoggedIn</option>',
        '<option title="mtifmaxresscutoff">IfMaxResultsCutoff</option>',
        '<option title="mtifmorress">IfMoreResults</option>',
        '<option title="mtifneeema">IfNeedEmail</option>',
        '<option title="mtifnonemp">IfNonEmpty</option>',
        '<option title="mtifnonzer">IfNonZero</option>',
        '<option title="mtifpinsacc">IfPingsAccepted</option>',
        '<option title="mtifpinsact">IfPingsActive</option>',
        '<option title="mtifpinsalled">IfPingsAllowed</option>',
        '<option title="mtifpinsmod">IfPingsModerated</option>',
        '<option title="mtifpreress">IfPreviousResults</option>',
        '<option title="mtifregalled">IfRegistrationAllowed</option>',
        '<option title="mtifregnotreq">IfRegistrationNotRequired</option>',
        '<option title="mtifregreq">IfRegistrationRequired</option>',
        '<option title="mtifreqcomemas">IfRequireCommentEmails</option>',
        '<option title="mtifsta">IfStatic</option>',
        '<option title="mtifstrsea">IfStraightSearch</option>',
        '<option title="mtiftagsea">IfTagSearch</option>',
        '<option title="mtiftypkeytok">IfTypeKeyToken</option>',
        '<option title="mtifweb">IfWebsite</option>',
        '<option title="mtign">Ignore</option>',
        '<option title="mtimacusdes">ImageCustomFieldDescription</option>',
        '<option title="mtimacusnam">ImageCustomFieldName</option>',
        '<option title="mtimacusval">ImageCustomFieldValue</option>',
        '<option title="mtimacuss">ImageCustomFields</option>',
        '<option title="mtimahei">ImageHeight</option>',
        '<option title="mtimaurl">ImageURL</option>',
        '<option title="mtimawid">ImageWidth</option>',
        '<option title="mtinc">Include</option>',
        '<option title="mtincblo">IncludeBlock</option>',
        '<option title="mtindbas">IndexBasename</option>',
        '<option title="mtindlin">IndexLink</option>',
        '<option title="mtindlis">IndexList</option>',
        '<option title="mtindnam">IndexName</option>',
        '<option title="mtlin">Link</option>',
        '<option title="mtloo">Loop</option>',
        '<option title="mtmaropts">MarkdownOptions</option>',
        '<option title="mtmaxress">MaxResults</option>',
        '<option title="mtmul">MultiBlog</option>',
        '<option title="mtmuliflocblo">MultiBlogIfLocalBlog</option>',
        '<option title="mtmullocblo">MultiBlogLocalBlog</option>',
        '<option title="mtnexlin">NextLink</option>',
        '<option title="mtnos">NoSearch</option>',
        '<option title="mtnosress">NoSearchResults</option>',
        '<option title="mtnot">NotifyScript</option>',
        '<option title="mtothblo">OtherBlog</option>',
        '<option title="mtothprovar">OtherProfileVar</option>',
        '<option title="mtothpros">OtherProfiles</option>',
        '<option title="mtpagasss">PageAssets</option>',
        '<option title="mtpagautdisnam">PageAuthorDisplayName</option>',
        '<option title="mtpagautema">PageAuthorEmail</option>',
        '<option title="mtpagautlin">PageAuthorLink</option>',
        '<option title="mtpagauturl">PageAuthorURL</option>',
        '<option title="mtpagbas">PageBasename</option>',
        '<option title="mtpagbod">PageBody</option>',
        '<option title="mtpagcusdes">PageCustomFieldDescription</option>',
        '<option title="mtpagcusnam">PageCustomFieldName</option>',
        '<option title="mtpagcusval">PageCustomFieldValue</option>',
        '<option title="mtpagcuss">PageCustomFields</option>',
        '<option title="mtpagdat">PageDate</option>',
        '<option title="mtpagexc">PageExcerpt</option>',
        '<option title="mtpagfol">PageFolder</option>',
        '<option title="mtpagid">PageID</option>',
        '<option title="mtpagiftagged">PageIfTagged</option>',
        '<option title="mtpagkey">PageKeywords</option>',
        '<option title="mtpagmoddat">PageModifiedDate</option>',
        '<option title="mtpagmor">PageMore</option>',
        '<option title="mtpagnex">PageNext</option>',
        '<option title="mtpagper">PagePermalink</option>',
        '<option title="mtpagpre">PagePrevious</option>',
        '<option title="mtpagtags">PageTags</option>',
        '<option title="mtpagtit">PageTitle</option>',
        '<option title="mtpagrblo">PagerBlock</option>',
        '<option title="mtpagrlin">PagerLink</option>',
        '<option title="mtpags">Pages</option>',
        '<option title="mtpagsfoo">PagesFooter</option>',
        '<option title="mtpagshea">PagesHeader</option>',
        '<option title="mtparcats">ParentCategories</option>',
        '<option title="mtparcat">ParentCategory</option>',
        '<option title="mtparfol">ParentFolder</option>',
        '<option title="mtparfols">ParentFolders</option>',
        '<option title="mtpinblonam">PingBlogName</option>',
        '<option title="mtpindat">PingDate</option>',
        '<option title="mtpinent">PingEntry</option>',
        '<option title="mtpinexc">PingExcerpt</option>',
        '<option title="mtpinid">PingID</option>',
        '<option title="mtpinip">PingIP</option>',
        '<option title="mtpinran">PingRank</option>',
        '<option title="mtpinsco">PingScore</option>',
        '<option title="mtpinscoavg">PingScoreAvg</option>',
        '<option title="mtpinscocou">PingScoreCount</option>',
        '<option title="mtpinscohig">PingScoreHigh</option>',
        '<option title="mtpinscolow">PingScoreLow</option>',
        '<option title="mtpintit">PingTitle</option>',
        '<option title="mtpinurl">PingURL</option>',
        '<option title="mtpins">Pings</option>',
        '<option title="mtpinsfoo">PingsFooter</option>',
        '<option title="mtpinshea">PingsHeader</option>',
        '<option title="mtpinssen">PingsSent</option>',
        '<option title="mtpinssenurl">PingsSentURL</option>',
        '<option title="mtprelin">PreviousLink</option>',
        '<option title="mtprodnam">ProductName</option>',
        '<option title="mtprofsers">ProfileServices</option>',
        '<option title="mtpubcha">PublishCharset</option>',
        '<option title="mtremsiginlin">RemoteSignInLink</option>',
        '<option title="mtremsigoutlin">RemoteSignOutLink</option>',
        '<option title="mtseaincblos">SearchIncludeBlogs</option>',
        '<option title="mtseamaxress">SearchMaxResults</option>',
        '<option title="mtsearescou">SearchResultCount</option>',
        '<option title="mtsearess">SearchResults</option>',
        '<option title="mtseascr">SearchScript</option>',
        '<option title="mtseastr">SearchString</option>',
        '<option title="mtseatemid">SearchTemplateID</option>',
        '<option title="mtsec">Section</option>',
        '<option title="mthash">SetHashVar</option>',
        '<option title="mtset">SetVar</option>',
        '<option title="mtsetblo">SetVarBlock</option>',
        '<option title="mtsettem">SetVarTemplate</option>',
        '<option title="mtsets">SetVars</option>',
        '<option title="mtsigonurl">SignOnURL</option>',
        '<option title="mtsmapanver">SmartyPantsVersion</option>',
        '<option title="mtstafilpat">StaticFilePath</option>',
        '<option title="mtstawebpat">StaticWebPath</option>',
        '<option title="mtstr">StreamAction</option>',
        '<option title="mtstrdat">StreamActionDate</option>',
        '<option title="mtstrid">StreamActionID</option>',
        '<option title="mtstrmoddat">StreamActionModifiedDate</option>',
        '<option title="mtstrolup">StreamActionRollup</option>',
        '<option title="mtstrtags">StreamActionTags</option>',
        '<option title="mtstrthuurl">StreamActionThumbnailURL</option>',
        '<option title="mtstrtit">StreamActionTitle</option>',
        '<option title="mtstrvar">StreamActionVar</option>',
        '<option title="mtstrvia">StreamActionVia</option>',
        '<option title="mtsubcatisfir">SubCatIsFirst</option>',
        '<option title="mtsubcatislas">SubCatIsLast</option>',
        '<option title="mtsubcats">SubCategories</option>',
        '<option title="mtsubcatpat">SubCategoryPath</option>',
        '<option title="mtsubcatsrec">SubCatsRecurse</option>',
        '<option title="mtsubfolrec">SubFolderRecurse</option>',
        '<option title="mtsubfols">SubFolders</option>',
        '<option title="mtsupdirurl">SupportDirectoryURL</option>',
        '<option title="mttagcou">TagCount</option>',
        '<option title="mttagid">TagID</option>',
        '<option title="mttaglab">TagLabel</option>',
        '<option title="mttagnam">TagName</option>',
        '<option title="mttagran">TagRank</option>',
        '<option title="mttagsealin">TagSearchLink</option>',
        '<option title="mttags">Tags</option>',
        '<option title="mttemcredon">TemplateCreatedOn</option>',
        '<option title="mttemcusdes">TemplateCustomFieldDescription</option>',
        '<option title="mttemcusnam">TemplateCustomFieldName</option>',
        '<option title="mttemcusval">TemplateCustomFieldValue</option>',
        '<option title="mttemcuss">TemplateCustomFields</option>',
        '<option title="mttemnote">TemplateNote</option>',
        '<option title="mttex">Textile</option>',
        '<option title="mttexheaoff">TextileHeadOffset</option>',
        '<option title="mttexopts">TextileOptions</option>',
        '<option title="mttopcats">TopLevelCategories</option>',
        '<option title="mttopfol">TopLevelFolder</option>',
        '<option title="mttopfols">TopLevelFolders</option>',
        '<option title="mttoppar">TopLevelParent</option>',
        '<option title="mttotpags">TotalPages</option>',
        '<option title="mttrascr">TrackbackScript</option>',
        '<option title="mttyptok">TypeKeyToken</option>',
        '<option title="mtunl">Unless</option>',
        '<option title="mtvar">Var</option>',
        '<option title="mtver">Version</option>',
        '<option title="mtvidcusdes">VideoCustomFieldDescription</option>',
        '<option title="mtvidcusnam">VideoCustomFieldName</option>',
        '<option title="mtvidcusval">VideoCustomFieldValue</option>',
        '<option title="mtvidcuss">VideoCustomFields</option>',
        '<option title="mtwebcclima">WebsiteCCLicenseImage</option>',
        '<option title="mtwebcclurl">WebsiteCCLicenseURL</option>',
        '<option title="mtwebcomcou">WebsiteCommentCount</option>',
        '<option title="mtwebcusdes">WebsiteCustomFieldDescription</option>',
        '<option title="mtwebcusnam">WebsiteCustomFieldName</option>',
        '<option title="mtwebcusval">WebsiteCustomFieldValue</option>',
        '<option title="mtwebcuss">WebsiteCustomFields</option>',
        '<option title="mtwebdes">WebsiteDescription</option>',
        '<option title="mtwebfilext">WebsiteFileExtension</option>',
        '<option title="mtwebhos">WebsiteHost</option>',
        '<option title="mtwebid">WebsiteID</option>',
        '<option title="mtwebifccl">WebsiteIfCCLicense</option>',
        '<option title="mtwebifcomsope">WebsiteIfCommentsOpen</option>',
        '<option title="mtweblan">WebsiteLanguage</option>',
        '<option title="mtwebnam">WebsiteName</option>',
        '<option title="mtwebpagcou">WebsitePageCount</option>',
        '<option title="mtwebpat">WebsitePath</option>',
        '<option title="mtwebpincou">WebsitePingCount</option>',
        '<option title="mtwebrelurl">WebsiteRelativeURL</option>',
        '<option title="mtwebtheid">WebsiteThemeID</option>',
        '<option title="mtwebtim">WebsiteTimezone</option>',
        '<option title="mtweburl">WebsiteURL</option>',
        '<option title="mtwebs">Websites</option>',
        '<option title="mtwidmon">WidgetManager</option>',
        '<option title="mtwidset">WidgetSet</option>',
        '<option title="mtxmlscr">XMLRPCScript</option>'
    ];
    
    // Insert <select> and <a>
    var tagSelecter = $('<select id="mttag_selecter"></select>');
    var fullScreen = $('<a id="full_screen" href="javascript:void(0);">全画面表示</a>');
    for (var i=0; i<mttags.length; i++) {
        tagSelecter.append(mttags[i]);
    }
    tmpl_body.prepend(fullScreen);
    tmpl_body.prepend(tagSelecter);

    // Events
    $('#full_screen').live('click', function(){
    
        var self = $(this);
        var scrollArry = getPageScroll()
        body.css('overflow','hidden');
        container.css('padding','0');
        
        self.attr('id','re_full_screen').text('全画面を閉じる');
        
        tmpl_body.css({
            'position': 'absolute',
            'z-index': '2000',
            'top': scrollArry[1] + 'px',
            'left': 0,
            'width':'100%',
            'height':getPageHeight() + 'px',
            'background-color': '#FFFFFF',
            'margin': '-30px 0',
            'padding': '40px 0'
        });
    });
    $('#re_full_screen').live('click', function(){
        $(this).attr('id','full_screen').text('全画面表示');
        body.removeAttr('style');
        container.removeAttr('style');
        tmpl_body.removeAttr('style');
    });
    
    $('#mttag_selecter option').click(function(){
        var title = $(this).attr('title');
        textarea.insertAtCaret(title);
    });

});
//]]>
